const glob = require('glob')
const path = require('path')

module.exports = setMpa = () => {
  const entry = {};
  const entryFiles = glob.sync(path.join(__dirname, "./src/js/*/*.js"));
  entryFiles.map((item, index) => {
    const entryFile = entryFiles[index];
    const match = entryFile.match(/src\/js\/(.*)\/(.*)\.js$/);
    const firstLetter = match[2].charAt(0)
    const firstLetterToUp = firstLetter.toUpperCase()
    const match1 = match[1]
    const match2 = firstLetterToUp + match[2].slice(1)
    let pageName = match1 + match2;
    pageName = pageName.replace('Index', '')
    entry[pageName] = entryFile;
  });
  console.log(entry)
  return entry
};